<?php
/**
 * LStyle is a widget that prepares CSS based on user settigns
 */
class LStyle extends CWidget
{
	private $_model=null;


	public function init()
	{	
		$model=$this->loadModel();
		$this->render('style',array('model'=>$model));
		
	}
	
	/**
	 * Returns the data model based on the primary key given in the GET variable.
	 * If the data model is not found, an HTTP exception will be raised.
	 */
	private function loadModel()
	{
		if($this->_model===null)
		{
				$criteria ='user='.Yii::app()->user->id;
				$this->_model=Style::model()->find($criteria);
			
			if($this->_model===null)
				$this->_model=new Style;	
				$this->_model->user=Yii::app()->user->id;
				$this->_model->save();
		}
		return $this->_model;
	}
}
?>




